<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<%--<jsp:include page="../../head.jsp"/>--%>
<title>修改用户权限 - 云超市</title>
<div class="row" style="margin-top: 30px;">
<div class="col-sm-2"></div>
<div class="col-sm-6" id="changRoleDiv">
	<form class="form-horizontal" role="form">
		<div class="form-group">
			<label for="inputUserPhone" class="col-sm-3 control-label">用户手机号：</label>
			<div class="col-sm-9">
				<input type="text" class="form-control" id="inputUserPhone"
					placeholder="输入用户的手机号" maxlength="11">
			</div>
		</div>
		<div class="form-group">
			<label  class="col-sm-3 control-label">用户角色：</label>
			<div class="col-sm-9">
				<select class="form-control" id="userRoleSelect">
					<option name="userRole" value="0">--请选择角色--</option>
					<option name="userRole" value="006">本部物流业/驾驶员</option>
					<option name="userRole" value="007">盘县物流业/驾驶员</option>
					<option name="userRole" value="002">客户经理</option>
					<option nane="userRole" value="003">店主</option>
					<option name="userRole" value="004">普通用户</option>
				</select>
			</div>
		</div>
<div style="color:red;margin-top: 7px;margin-left: 240px;" class="hide" id="errorInfo">请输入手机号</div>
		<div class="form-group">
			<div class="col-sm-offset-9 col-sm-4">
				<button style="margin-top: 10px; margin-left: 25px;" type="button" id="confrimChangeRole" class="btn btn-success btn-sm">确认修改</button>
			</div>
		</div>
	</form>
</div>
<div class="col-sm-3">

</div>
</div>

<script type="text/javascript">
$("#confrimChangeRole").click(function() {

	var phone = $("#inputUserPhone").val();
	var flag = checkSubmitMobil(phone);
	if(!flag)return;
	var role = $("#userRoleSelect").val();
	
	if(role==0){
		//alert("请选择要修改的角色");
		$("#errorInfo").html("请选择要修改的角色");
		$("#errorInfo").removeClass("hide");
		return;
	}
	$("#errorInfo").html("正在处理，请等待结果...");
	$("#errorInfo").removeClass("hide");
	$.ajax({
		url : "${contextPath}/sys/clouderp/changeRole",
		dataType : "json",
		type : "post",
		data : {
			phone : phone,
			role : role
		},
		async : false,
		success : function(data){
			//alert(data.message);
			$("#errorInfo").html(data.message);
			$("#errorInfo").removeClass("hide");
		},
		error : function(result){
			//alert("未知错误");
			$("#errorInfo").html("服务器错误");
			$("#errorInfo").removeClass("hide");
		}
	});
});

function checkSubmitMobil(mobil) { 
	if (mobil == "") { 
	//alert("手机号码不能为空！"); 
	$("#errorInfo").html("手机号码不能为空");
	$("#errorInfo").removeClass("hide");
	
	return false; 
	} 
	var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
	if(!myreg.test(mobil)) 
	{ 
	    //alert('请输入有效的手机号码'); 
	    $("#errorInfo").html("请输入有效的手机号码");
		$("#errorInfo").removeClass("hide");
	    return false; 
	}
	$("#errorInfo").addClass("hide");
	return true; 
	} 
</script>


